// This KEPServerEX/UA example shows how to read value of a single node, and display it.
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples.Specialized
{
partial class Kepware_KEPServerEX_UA
{
public static void ReadValue()
{
UAEndpointDescriptor endpointDescriptor = "opc.tcp://localhost:49320"; // default KEPServerEX/UA endpoint
// Instantiate the client object.
var client = new EasyUAClient();
Console.WriteLine("Obtaining value of a node...");
object value;
try
{
value = client.ReadValue(endpointDescriptor,
// The UANodeId.KEPServerEX(...) helper method simplifies creation of node IDs for KEPServerEX/UA nodes.
UANodeId.KEPServerEX("Simulation Examples.Functions.Random1"));
}
catch (UAException uaException)
{
Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
return;
}
// Display results
Console.WriteLine($"value: {value}");
}
}
}